package com.qisimanxiang.workreport.dalaran.protocol.config;


import com.qisimanxiang.workreport.dalaran.protocol.config.http.DalaranHttpInitProcessor;
import com.qisimanxiang.workreport.dalaran.protocol.starter.DalaranStarter;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Import;

import javax.annotation.PostConstruct;
import java.io.Serializable;

/**
 * @author wangmeng
 * @date 2019-08-05
 */
@ConfigurationProperties(
        prefix = "dalaran",
        ignoreUnknownFields = true
)
@Data
@Slf4j
@Import({DalaranStarter.class, DalaranHttpInitProcessor.class})
public class DalaranConfig {
    private HttpConfig http;


    @Data
    public static class HttpConfig implements Serializable {
        private static final long serialVersionUID = 5759066465018627904L;
        private Integer port;
        private Integer maxContent;
    }

    @PostConstruct
    void init() {
        if (http == null) {
            http = new HttpConfig();
            http.port = 8080;
            http.maxContent = 512 * 1024;
        }
        log.info(this.getClass().getSimpleName() + " init success.");
    }
}
